<?php

class Controller
{
	public $route;
	public $front_controller;
	public $registry;
	public $view;
	public function __construct()
	{
		$this->registry=Registry::getInstance();
		$this->route=$this->registry->get("route");
		$this->front_controller=$this->registry->get("frontcontroller");
		Loader::load($this->front_controller->getRootDir()."library/view.php");
		$this->view=new View();
	}
	public function getControllerName()
	{
		return $this->route->getControllerName();
	}
	
	public function getModuleName()
	{
		return $this->route->getModuleName();
	}
	
	public  function getActionName()
	{
		return $this->route->getActionName();
	}
	
	public function getBaseUrl()
	{
		return $this->front_controller->getBaseUrl();
	}
	
	public function getRootDir()
	{
		return $this->front_controller->getRootDir();
	}
	
	public function display($view="")
	{
		if(!empty($view))
		{
			$this->view->setView($view);
		}
		$this->view->display();
	}
	
	public function setLayout($layout,$module="")
	{
		$this->view->setLayout($layout);
		if(!empty($module))
		{
			$this->view->setLayoutModule($module);
		}
	}
}